<?php
/**
 * Short description for class
 *
 * Long description for class (if any)...
 *
 * @category   Sabai
 * @package    Sabai_Controller
 * @copyright  Copyright (c) 2008 myWeb Japan (http://www.myweb.ne.jp/)
 * @author     Kazumi Ono <onokazu@gmail.com>
 * @license    http://opensource.org/licenses/lgpl-license.php GNU LGPL
 * @link
 * @since      Class available since Release 0.1.9a3
 */
class Sabai_Controller_Context
{
    /**
     * @access protected
     * @var array
     */
    var $_context = array();

    /**
     * Constructor for PHP4. Initializes variables to mimic PHP5 __get()/__set().
     *
     * @param Sabai_Request $request
     * @param Sabai_Response $response
     * @param Sabai_User $user
     * @param Sabai_Config $config
     * @return Sabai_Controller_Context
     */
    function Sabai_Controller_Context(&$request, &$response, &$user, &$config)
    {

        $this->request =& $request;
        $this->response =& $response;
        $this->user =& $user;
        $this->config =& $config;
        $this->_context['request'] =& $this->request;
        $this->_context['response'] =& $this->response;
        $this->_context['user'] =& $this->user;
        $this->_context['config'] =& $this->config;
    }

    /**
     * Constructor for PHP5
     *
     * @param Sabai_Request $request
     * @param Sabai_Response $response
     * @param Sabai_User $user
     * @param Sabai_Config $config
     * @return Sabai_Controller_Context
     */
    function __construct($request, $response, $user, $config)
    {
        $this->_context['request'] = $request;
        $this->_context['response'] = $response;
        $this->_context['user'] = $user;
        $this->_context['config'] = $config;
    }

    /**
     * PHP magic method
     *
     * @param string $name
     * @return mixed
     */
    function __get($name)
    {
        if (array_key_exists($name, $this->_context)) {
            return $this->_context[$name];
        }
        return null;
    }
}